package book_management.operation.impl;

import book_management.book.BookList;
import book_management.operation.IOperation;

public class AddOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("您现在进行的是添加书籍操作~");
        System.out.println("请您输入要添加的书籍名称");
        String booksName = scanner.nextLine();
        //假设书架上已经有这本书了~
        if (bookList.contains(booksName)){
            System.err.println(booksName+"当前书籍已经在书架上存在了，无需添加");
         return ;
        }
        System.out.println("请输入您要添加的书籍作者：");
        String author = scanner.nextLine();
        System.out.println("请您输入您要添加的书籍类别：");
        String type = scanner.nextLine();
        System.out.println("请您输入您要添加的书籍价格：");
        double price = scanner.nextDouble();
        //产生书籍对象，保存到书架上
        bookList.addNewBook(booksName,author,type,price);
        System.out.println("添加书籍成功~");
    }
}
